#ifndef _SWI_H_
#define _SWI_H_

#include "armdefs.h"
#include <stdbool.h>

#define OS_WriteC 0x00000000
#define OS_WriteS 0x00000001
#define OS_Write0 0x00000002
#define OS_NewLine 0x00000003
#define OS_ReadC 0x00000004
#define OS_CLI 0x00000005
#define OS_Byte 0x00000006
#define OS_Word 0x00000007
#define OS_File 0x00000008
#define OS_Args 0x00000009
#define OS_BGet 0x0000000A
#define OS_BPut 0x0000000B
#define OS_GBPB 0x0000000C
#define OS_Find 0x0000000D
#define OS_ReadLine 0x0000000E
#define OS_Control 0x0000000F
#define OS_GetEnv 0x00000010
#define OS_Exit 0x00000011
#define OS_SetEnv 0x00000012
#define OS_IntOn 0x00000013
#define OS_IntOff 0x00000014
#define OS_CallBack 0x00000015
#define OS_EnterOS 0x00000016
#define OS_BreakPt 0x00000017
#define OS_BreakCtrl 0x00000018
#define OS_UnusedSWI 0x00000019
#define OS_UpdateMEMC 0x0000001A
#define OS_SetCallBack 0x0000001B
#define OS_Mouse 0x0000001C
#define OS_Heap 0x0000001D
#define OS_Module 0x0000001E
#define OS_Claim 0x0000001F
#define OS_Release 0x00000020
#define OS_ReadUnsigned 0x00000021
#define OS_GenerateEvent 0x00000022
#define OS_ReadVarVal 0x00000023
#define OS_SetVarVal 0x00000024
#define OS_GSInit 0x00000025
#define OS_GSRead 0x00000026
#define OS_GSTrans 0x00000027
#define OS_BinaryToDecimal 0x00000028
#define OS_FSControl 0x00000029
#define OS_ChangeDynamicArea 0x0000002A
#define OS_GenerateError 0x0000002B
#define OS_ReadEscapeState 0x0000002C
#define OS_EvaluateExpression 0x0000002D
#define OS_SpriteOp 0x0000002E
#define OS_ReadPalette 0x0000002F
#define OS_ServiceCall 0x00000030
#define OS_ReadVduVariables 0x00000031
#define OS_ReadPoint 0x00000032
#define OS_UpCall 0x00000033
#define OS_CallAVector 0x00000034
#define OS_ReadModeVariable 0x00000035
#define OS_RemoveCursors 0x00000036
#define OS_RestoreCursors 0x00000037
#define OS_SWINumberToString 0x00000038
#define OS_SWINumberFromString 0x00000039
#define OS_ValidateAddress 0x0000003A
#define OS_CallAfter 0x0000003B
#define OS_CallEvery 0x0000003C
#define OS_RemoveTickerEvent 0x0000003D
#define OS_InstallKeyHandler 0x0000003E
#define OS_CheckModeValid 0x0000003F
#define OS_ChangeEnvironment 0x00000040
#define OS_ClaimScreenMemory 0x00000041
#define OS_ReadMonotonicTime 0x00000042
#define OS_SubstituteArgs 0x00000043
#define OS_PrettyPrint 0x00000044
#define OS_Plot 0x00000045
#define OS_WriteN 0x00000046
#define OS_AddToVector 0x00000047
#define OS_WriteEnv 0x00000048
#define OS_ReadArgs 0x00000049
#define OS_ReadRAMFsLimits 0x0000004A
#define OS_ClaimDeviceVector 0x0000004B
#define OS_ReleaseDeviceVector 0x0000004C
#define OS_DelinkApplication 0x0000004D
#define OS_RelinkApplication 0x0000004E
#define OS_HeapSort 0x0000004F
#define OS_ExitAndDie 0x00000050
#define OS_ReadMemMapInfo 0x00000051
#define OS_ReadMemMapEntries 0x00000052
#define OS_SetMemMapEntries 0x00000053
#define OS_AddCallBack 0x00000054
#define OS_ReadDefaultHandler 0x00000055
#define OS_SetECFOrigin 0x00000056
#define OS_SerialOp 0x00000057
#define OS_ReadSysInfo 0x00000058
#define OS_Confirm 0x00000059
#define OS_ChangedBox 0x0000005A
#define OS_CRC 0x0000005B
#define OS_ReadDynamicArea 0x0000005C
#define OS_PrintChar 0x0000005D
#define OS_ChangeRedirection 0x0000005E
#define OS_RemoveCallBack 0x0000005F
#define OS_FindMemMapEntries 0x00000060
#define OS_SetColour 0x00000061
#define OS_ClaimSWI 0x00000062
#define OS_ReleaseSWI 0x00000063
#define OS_Pointer 0x00000064
#define OS_ScreenMode 0x00000065
#define OS_DynamicArea 0x00000066
#define OS_AbortTrap 0x00000067
#define OS_Memory 0x00000068
#define OS_ClaimProcessorVector 0x00000069
#define OS_Reset 0x0000006A
#define OS_MMUControl 0x0000006B
#define OS_ResyncTime 0x0000006C
#define OS_PlatformFeatures 0x0000006D
#define OS_SynchroniseCodeAreas 0x0000006E
#define OS_CallASWI 0x0000006F
#define OS_AMBControl 0x00000070
#define OS_CallASWIR12 0x00000071
#define OS_SpecialControl 0x00000072
#define OS_EnterUSR32 0x00000073
#define OS_EnterUSR26 0x00000074
#define OS_VIDCDivider 0x00000075
#define OS_NVMemory 0x00000076
#define OS_Hardware 0x0000007A
#define OS_IICOp 0x0000007B
#define OS_LeaveOS 0x0000007C
#define OS_ReadLine32 0x0000007D
#define OS_SubstituteArgs32 0x0000007E
#define OS_HeapSort32 0x0000007F
#define OS_ConvertStandardDateAndTime 0x000000C0
#define OS_ConvertDateAndTime 0x000000C1
#define OS_ConvertHex1 0x000000D0
#define OS_ConvertHex2 0x000000D1
#define OS_ConvertHex4 0x000000D2
#define OS_ConvertHex6 0x000000D3
#define OS_ConvertHex8 0x000000D4
#define OS_ConvertCardinal1 0x000000D5
#define OS_ConvertCardinal2 0x000000D6
#define OS_ConvertCardinal3 0x000000D7
#define OS_ConvertCardinal4 0x000000D8
#define OS_ConvertInteger1 0x000000D9
#define OS_ConvertInteger2 0x000000DA
#define OS_ConvertInteger3 0x000000DB
#define OS_ConvertInteger4 0x000000DC
#define OS_ConvertBinary1 0x000000DD
#define OS_ConvertBinary2 0x000000DE
#define OS_ConvertBinary3 0x000000DF
#define OS_ConvertBinary4 0x000000E0
#define OS_ConvertSpacedCardinal1 0x000000E1
#define OS_ConvertSpacedCardinal2 0x000000E2
#define OS_ConvertSpacedCardinal3 0x000000E3
#define OS_ConvertSpacedCardinal4 0x000000E4
#define OS_ConvertSpacedInteger1 0x000000E5
#define OS_ConvertSpacedInteger2 0x000000E6
#define OS_ConvertSpacedInteger3 0x000000E7
#define OS_ConvertSpacedInteger4 0x000000E8
#define OS_ConvertFixedNetStation 0x000000E9
#define OS_ConvertNetStation 0x000000EA
#define OS_ConvertFixedFileSize 0x000000EB
#define OS_ConvertFileSize 0x000000EC
#define OS_ConvertHex16 0x000000ED
#define OS_ConvertCardinal8 0x000000EE
#define OS_ConvertInteger8 0x000000EF
#define OS_ConvertBinary8 0x000000F0
#define OS_ConvertSpacedCardinal8 0x000000F1
#define OS_ConvertSpacedInteger8 0x000000F2
#define OS_ConvertFixedFileSize64 0x000000F3
#define OS_ConvertFileSize64 0x000000F4
#define OS_WriteI 0x00000100

void 	WriteI(ARMword data);
void 	Write0(ARMul_State *state);
void 	WriteN(ARMul_State *state);
void 	WriteS(ARMul_State *state);

void 	OSByte129	(ARMul_State *state);
void 	OSByte161	(ARMul_State *state);
void 	OSByte3	(ARMword mask);

bool 	OSByte(ARMul_State *state);
bool 	SWIHandler(ARMul_State *state, ARMword swicode);


#endif
